package com.funtonow.jqdk.adapter;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.funtonow.jqdk.R;
import com.funtonow.jqdk.bean.JhjlBean;
import com.funtonow.jqdk.utils.TimeUtils;

/**
 * @author Jiajien
 * @date 2019/8/23
 */
public class JhAdapter extends BaseQuickAdapter<JhjlBean, BaseViewHolder> {

    private int jhType;

    public JhAdapter(int jhType) {
        super(R.layout.item_dk_jhjl);
        this.jhType = jhType;
    }

    @Override
    protected void convert(BaseViewHolder helper, JhjlBean item) {
        if (jhType == 0) {
            if (item.getState() >= 3) {
                helper.setText(R.id.tv_dk_time, TimeUtils.longToTime(item.getCreatetime()));
                helper.setText(R.id.tv_dk_num, "借款" + item.getSjdkje() + ".00元")
                        .setVisible(R.id.tv_dk_state, false);
                switch (item.getState()) {
                    case 3:
                        helper.setText(R.id.tv_dk_state, "下款");
                        break;
                    case 4:
                        helper.setText(R.id.tv_dk_state, "还款中");
                        break;
                    case 5:
                        helper.setText(R.id.tv_dk_state, "结束");
                        break;
                    default:
                        break;
                }
            }
        } else {
            helper.setText(R.id.tv_dk_time, TimeUtils.longToTime(item.getTime()));
            helper.setText(R.id.tv_dk_num, "还款" + (item.getBenjin() + item.getXifei()) + ".00元")
                    .setVisible(R.id.tv_dk_state, true);
            switch (item.getStatus()) {
                case 2:
                    helper.setText(R.id.tv_dk_state, "还款中");
                    break;
                case 3:
                    helper.setText(R.id.tv_dk_state, "逾期");
                    break;
                case 4:
                    helper.setText(R.id.tv_dk_state, "还款成功");
                    break;
                default:
                    break;
            }

        }
    }

}
